package com.tanhua.admin.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.pojo.Analysis;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface AnalysisMapper extends BaseMapper<Analysis> {

    @Select("select sum(num_registered) from tb_analysis")
    Long cumulativeUsers();

    //查询一段时间的活跃用户
    @Select("select sum(num_active) from tb_analysis where record_date between #{endDate} and #{startDate}")
    Long activePass(@Param("startDate")String startDate, @Param("endDate") String endDate);


    //统计每日新增用户
    @Select("select num_registered from tb_analysis where record_date = #{date}")
    Long registerPass(@Param("date")String date);


    //统计每日活跃用户
    @Select("select num_active from tb_analysis where record_date = #{date}")
    Integer thisDayActivePass(@Param("date")String date);

    /*昨天登陆,今天还在的数量 ,查log表*/




//    //查询一个月的活跃用户
//    @Select(" SELECT count(num_active) FROM tb_analysis where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(record_date)")
//    Integer activePassMonth(String lastMonth);


}
